package com.hy.main.demo.io;

import org.junit.Test;

import java.io.FileWriter;
import java.io.IOException;

/**
 * @Author shy Boy
 * @Date 2022/4/26 - 04 - 26 - 18:18
 * @Description: com.hy.main.demo.file
 * @version: 1.0
 */
public class FileWrites {


    public static void main(String[] args) {

    }

    /**
     *  字符输出流Demo
     * @throws IOException
     */
    @Test
    public void fileWritesDemo() throws IOException {
        String path = "E:\\add.txt";
        FileWriter fileWriter = null;
        try {
             fileWriter = new FileWriter(path);
             fileWriter.write("123456");
        }catch (IOException e){
            e.printStackTrace();
        }finally {
            // 一定要关闭流或者刷新流 否则写入不到文件里面
            fileWriter.close();
        }
    }
}
